#include <MyPlugin/main/enter_scope.h>

// It is absolutely neccessary to force the include of the enter_scope of CLI
// and XCLI libraries in the main so that the Commands creators table is
// properly created. Otherwise, Gocad on Windows can not run any CLI commands

#include <MyPlugin/CLI/enter_scope.h>
#include <MyPlugin/XCLI/enter_scope.h>
#include <MyPlugin/main/MyPlugin_main_init.h>
#include <MyPlugin/main/ToolBar.h>

#include <Gocad/utils/misc/plugin_manager.h>

#include <Gocad/gui/gocad/xmmain.h>
#include <Gocad/gui/gocad/xmguilib.h>
#include <Gocad/gui/gocad/xmarchivelib.h>

#include <Gocad/qtools/gqtabwidget.h> 
#include <Gocad/qtools/gqutils.h>

using namespace Gocad;

namespace MyPlugin {
	extern "C" __declspec(dllexport) 
		PluginRuntime* _GOCAD_PLUGIN_RUNTIME_CREATOR(MyPlugin)(Plugin* p) { 
			return new _GOCAD_PLUGIN_RUNTIME_CLASS(MyPlugin)(p); 
	}

	MyPlugin_runtime::MyPlugin_runtime(Plugin* p)
		: PluginRuntime(p)
	{
	}

	MyPlugin_runtime::~MyPlugin_runtime()
	{
	}

	bool MyPlugin_runtime::start()
	{		
		return true;
	}

	bool MyPlugin_runtime::init_gui()
	{
		Gocad::XMMainWindow* xmw = GocadGuiLib::instance()->main_window();
		ASSERT(xmw!=NULL);

		GQTabDockWindowGroup* wins = NULL;
		wins = xmw->task_pane();
		ASSERT(wins!=NULL);

		new ToolBar(xmw->qmain_window(), "toolbar");

		return true;
	}

	void MyPlugin_runtime::finalize_gui()
	{
	}

	void MyPlugin_runtime::stop()
	{
	}
	
	GOCAD_LIBRARY_INITIALIZE(MyPlugin,main) { }
	GOCAD_LIBRARY_TERMINATE(MyPlugin,main) { }

} // namespace MyPlugin

